package test;
import nme.display.Sprite;
import nme.events.MouseEvent;
import nme.events.TouchEvent;

/**
 * ...
 * @author liwei
 */

class TestMouse extends TestBase
{
	private var sp:Sprite;
	public function new() 
	{
		super();
		
	}
	override public function start():Void 
	{
		super.start();
		var mMultiTouch:Bool = nme.ui.Multitouch.supportsTouchEvents;
		if (mMultiTouch) {
			nme.ui.Multitouch.inputMode = nme.ui.MultitouchInputMode.TOUCH_POINT;
		}
		log("Using multi-touch : " + mMultiTouch);
		sp = new Sprite();
		addChild(sp);
		sp.graphics.beginFill(0xff0000);
		sp.graphics.drawRect(0, 0, 100, 100);
		sp.graphics.endFill();
		sp.addEventListener(MouseEvent.CLICK, mousehandler);
		sp.addEventListener(MouseEvent.MOUSE_DOWN, mousehandler);
		sp.addEventListener(MouseEvent.MOUSE_OVER, mousehandler);
		sp.addEventListener(MouseEvent.MOUSE_OUT, mousehandler);
		sp.addEventListener(TouchEvent.TOUCH_TAP, mousehandler);
		sp.x = sp.y = 100;
	}
	
	private function mousehandler(e:MouseEvent):Void 
	{
		var type:String = e.type;
		log(type);
		if (type == MouseEvent.MOUSE_OVER) {
			sp.alpha = 0.5;
		}else if (type == MouseEvent.MOUSE_OUT) {
			sp.alpha = 1;
		}else {
			
		}
	}
	
}